package java学习.奇安信;

import java.util.Scanner;

/**
 * **************
 * 项目名称: 蓝桥杯-Java学习 <br/>
 * 文件名称:  <br/>
 * 文件描述: 这里添加您的类文件描述，说明当前文件要包含的功能。 <br/>
 * 文件创建：刘世锦Lenovo <br/>
 * 创建时间: 2022/9/15 <br/>
 *
 * @version v1.0 <br/>
 * @update [序号][日期YYYY-MM-DD][更改人姓名][变更描述]<br/>
 * *************
 */
public class 蚂蚁吃食物 {


        /**
         * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
         *
         * 得到最短路径长度
         * @param points int整型二维数组 食物位置
         * @return int整型
         */
        public static int getMinLen (int[][] points) {
            int num = 0;

            for (int i = 0; i < points.length-1; i++) {
                    if ((points[i][0] == points[i+1][0])||(points[i][1] == points[i+1][1])) {
                        num = Math.max(points[i][0]+points[i][1], points[i+1][0]+points[i+1][1]);
                    }else{
                        num+=  points[i][0]+points[i][1]+ points[i+1][0]+points[i+1][1];
                }
            }
            return num;
        }
    public static int getMinLen ( ) {
        Scanner in = new Scanner(System.in);
        String  a = in.nextLine();
        String  b = in.nextLine();
        int c = 0;
        String[] split1 = a.split(",");
        String[] split2 = b.split(",");
        for (int i = 0; i < split1.length; i++) {
            c+=Math.min(Integer.parseInt(split1[i]),Integer.parseInt(split2[i]));
        }
        System.out.println(c);
        return c;
    }
    public static void main(String[] args) {
//        int[][] arr  = {{0,5},{1,1}};
        int[][] arr  = {{0,1},{0,2},{0,3}};

        System.out.println(getMinLen(arr));
    }


    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            // 注意，如果输入是多个测试用例，请通过while循环处理多个测试用例
            String  a = in.nextLine();
            String  b = in.nextLine();
            int c = 0;
            String[] split1 = a.split(",");
            String[] split2 = b.split(",");
            for (int i = 0; i < split1.length; i++) {
                c+=Math.min(Integer.parseInt(split1[i]),Integer.parseInt(split2[i]));
            }
            System.out.println(c);
        }
    }

}
/**
 *         for (int i = 0; i < points.length; i++) {
 *                 for (int j = 0; j < points[0].length; j++) {
 *                     System.out.print (points[i][j]+" ");
 *                 }
 *                 System.out.println();
 *             }
 */